<?php

namespace App;

class Post extends Base
{
    protected $guarded = [];

    public function setIsPublishedAttribute($value)
    {
        $this->attributes['is_published'] = $value ? 'T' : 'F';
    }

    public function getIsPublishedAttribute($value)
    {
        return $value === 'T' ? true : false;
    }

    public function category()
    {
        return $this->belongSTo('App\Category');
    }

    public function attachments()
    {
        return $this->morphMany('App\Attachment', 'attachmentable');
    }
}
